# coding = utf-8


def fib(maxNum):
    n, a, b = 0, 0, 1
    while n < maxNum:
        yield b
        a, b = b, a+b
        n = n+1
    # return 的作用就是异常时候返回的消息
    return "done hahaha"


f = fib(10)

while True:
    try:
        # x = next(f)  # 等同
        x = f.__next__()
        print("f:", x)
    except StopIteration as e:
        print("return values:", e.value)
        break


